home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_55_Message Sprite .ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  3.0 KB  |  97 lines

  1. property whichevent, Addressee, EventToSend, DownCM, UpCM, DownNum, UpNum, button_active
  2.  
  3. on beginSprite me
  4.   set the UpCM of me to the member of sprite the spriteNum of me
  5.   set the UpNum of me to the number of member UpCM
  6.   set the DownNum of me to the number of member DownCM
  7.   set the button_active of me to 0
  8.   puppetSprite(the spriteNum of me, 1)
  9. end
  10.  
  11. on endSprite me
  12.   puppetSprite(the spriteNum of me, 0)
  13. end
  14.  
  15. on triggerSendSprite me
  16.   trigger(me)
  17. end
  18.  
  19. on mouseUp me
  20.   set the member of sprite the spriteNum of me to UpNum
  21.   set the button_active of me to 0
  22.   if whichevent = #mouseUp then
  23.     trigger(me)
  24.   end if
  25. end
  26.  
  27. on mouseDown me
  28.   set the member of sprite the spriteNum of me to DownNum
  29.   set the button_active of me to 1
  30.   if whichevent = #mouseDown then
  31.     trigger(me)
  32.   end if
  33. end
  34.  
  35. on mouseUpOutSide me
  36.   set the button_active of me to 0
  37. end
  38.  
  39. on mouseLeave me
  40.   if the button_active of me then
  41.     set the member of sprite the spriteNum of me to UpNum
  42.   end if
  43. end
  44.  
  45. on mouseEnter me
  46.   if the button_active of me then
  47.     set the member of sprite the spriteNum of me to DownNum
  48.   end if
  49. end
  50.  
  51. on prepareFrame me
  52.   if whichevent = #prepareFrame then
  53.     trigger(me)
  54.   end if
  55. end
  56.  
  57. on enterFrame me
  58.   if whichevent = #enterFrame then
  59.     trigger(me)
  60.   end if
  61. end
  62.  
  63. on exitFrame me
  64.   if whichevent = #exitFrame then
  65.     trigger(me)
  66.   end if
  67. end
  68.  
  69. on trigger me
  70.   sendSprite(the Addressee of me, the EventToSend of me)
  71. end
  72.  
  73. on getPropertyDescriptionList
  74.   set description to [:]
  75.   if the currentSpriteNum = 0 then
  76.     set memdefault to 0
  77.   else
  78.     set memref to the member of sprite the currentSpriteNum
  79.     set castLibNum to the castLibNum of memref
  80.     set memdefault to member (the memberNum of member memref + 1) of castLib castLibNum
  81.   end if
  82.   addProp(description, #DownCM, [#default: memdefault, #format: #bitmap, #comment: "Pict for Down:"])
  83.   addProp(description, #EventToSend, [#comment: "Message:", #format: #symbol, #default: #CycleState])
  84.   addProp(description, #Addressee, [#comment: "Target Sprite:", #format: #integer, #default: the currentSpriteNum + 1])
  85.   addProp(description, #whichevent, [#comment: "Triggering Event:", #format: #symbol, #range: [#mouseUp, #mouseDown, #prepareFrame, #enterFrame, #exitFrame], #default: #mouseUp])
  86.   return description
  87. end
  88.  
  89. on getBehaviorDescription
  90.   return "Send a Message to the designated Sprite when the specified Event occurs.  At its destination the message will be interpreted as a sprite event and any actions defined for that event will be invoked." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Message - name of event to invoke at target sprite." & RETURN & "ΓÇó Target Sprite - number of sprite channel to which message should be sent." & RETURN & "ΓÇó Triggering Event - event that should cause message to be sent." & RETURN & "NOTES:" & RETURN & "If the target sprite does not handle the message it will propagate to the cast member script, the current frame script, and then the movie, in search of a handler for that event."
  91. end
  92.  
  93. on getAssocMembers
  94.   set myPropList to [DownCM]
  95.   return myPropList
  96. end
  97.